<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This file documents the use of the GNU compilers.

Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Invoking GCC (Using the GNU Compiler Collection (GCC))</title>

<meta name="description" content="Invoking GCC (Using the GNU Compiler Collection (GCC))">
<meta name="keywords" content="Invoking GCC (Using the GNU Compiler Collection (GCC))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Indices.html" rel="index" title="Indices">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="index.html" rel="up" title="Top">
<link href="C-Implementation.html" rel="next" title="C Implementation">
<link href="Standards.html" rel="prev" title="Standards">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
kbd.key {font-style: normal}
span:hover a.copiable-link {visibility: visible}
-->
</style>


</head>

<body lang="en_US">
<div class="chapter-level-extent" id="Invoking-GCC">
<div class="nav-panel">
<p>
Next: <a href="C-Implementation.html" accesskey="n" rel="next">C Implementation-Defined Behavior</a>, Previous: <a href="Standards.html" accesskey="p" rel="prev">Language Standards Supported by GCC</a>, Up: <a href="index.html" accesskey="u" rel="up">Introduction</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h2 class="chapter" id="GCC-Command-Options"><span>3 GCC Command Options<a class="copiable-link" href="#GCC-Command-Options"> &para;</a></span></h2>
<a class="index-entry-id" id="index-GCC-command-options"></a>
<a class="index-entry-id" id="index-command-options"></a>
<a class="index-entry-id" id="index-options_002c-GCC-command"></a>

<p>When you invoke GCC, it normally does preprocessing, compilation,
assembly and linking.  The &ldquo;overall options&rdquo; allow you to stop this
process at an intermediate stage.  For example, the <samp class="option">-c</samp> option
says not to run the linker.  Then the output consists of object files
output by the assembler.
See <a class="xref" href="Overall-Options.html">Options Controlling the Kind of Output</a>.
</p>
<p>Other options are passed on to one or more stages of processing.  Some options
control the preprocessor and others the compiler itself.  Yet other
options control the assembler and linker; most of these are not
documented here, since you rarely need to use any of them.
</p>
<a class="index-entry-id" id="index-C-compilation-options"></a>
<p>Most of the command-line options that you can use with GCC are useful
for C programs; when an option is only useful with another language
(usually C++), the explanation says so explicitly.  If the description
for a particular option does not mention a source language, you can use
that option with all supported languages.
</p>
<a class="index-entry-id" id="index-cross-compiling"></a>
<a class="index-entry-id" id="index-specifying-machine-version"></a>
<a class="index-entry-id" id="index-specifying-compiler-version-and-target-machine"></a>
<a class="index-entry-id" id="index-compiler-version_002c-specifying"></a>
<a class="index-entry-id" id="index-target-machine_002c-specifying"></a>
<p>The usual way to run GCC is to run the executable called <code class="command">gcc</code>, or
<code class="command"><var class="var">machine</var>-gcc</code> when cross-compiling, or
<code class="command"><var class="var">machine</var>-gcc-<var class="var">version</var></code> to run a specific version of GCC.
When you compile C++ programs, you should invoke GCC as <code class="command">g++</code> 
instead.  See <a class="xref" href="Invoking-G_002b_002b.html">Compiling C++ Programs</a>, 
for information about the differences in behavior between <code class="command">gcc</code> 
and <code class="command">g++</code> when compiling C++ programs.
</p>
<a class="index-entry-id" id="index-grouping-options"></a>
<a class="index-entry-id" id="index-options_002c-grouping"></a>
<p>The <code class="command">gcc</code> program accepts options and file names as operands.  Many
options have multi-letter names; therefore multiple single-letter options
may <em class="emph">not</em> be grouped: <samp class="option">-dv</samp> is very different from &lsquo;<samp class="samp">-d&nbsp;-v</samp>&rsquo;<!-- /@w -->.
</p>
<a class="index-entry-id" id="index-order-of-options"></a>
<a class="index-entry-id" id="index-options_002c-order"></a>
<p>You can mix options and other arguments.  For the most part, the order
you use doesn&rsquo;t matter.  Order does matter when you use several
options of the same kind; for example, if you specify <samp class="option">-L</samp> more
than once, the directories are searched in the order specified.  Also,
the placement of the <samp class="option">-l</samp> option is significant.
</p>
<p>Many options have long names starting with &lsquo;<samp class="samp">-f</samp>&rsquo; or with
&lsquo;<samp class="samp">-W</samp>&rsquo;&mdash;for example,
<samp class="option">-fmove-loop-invariants</samp>, <samp class="option">-Wformat</samp> and so on.  Most of
these have both positive and negative forms; the negative form of
<samp class="option">-ffoo</samp> is <samp class="option">-fno-foo</samp>.  This manual documents
only one of these two forms, whichever one is not the default.
</p>
<p>Some options take one or more arguments typically separated either
by a space or by the equals sign (&lsquo;<samp class="samp">=</samp>&rsquo;) from the option name.
Unless documented otherwise, an argument can be either numeric or
a string.  Numeric arguments must typically be small unsigned decimal
or hexadecimal integers.  Hexadecimal arguments must begin with
the &lsquo;<samp class="samp">0x</samp>&rsquo; prefix.  Arguments to options that specify a size
threshold of some sort may be arbitrarily large decimal or hexadecimal
integers followed by a byte size suffix designating a multiple of bytes
such as <code class="code">kB</code> and <code class="code">KiB</code> for kilobyte and kibibyte, respectively,
<code class="code">MB</code> and <code class="code">MiB</code> for megabyte and mebibyte, <code class="code">GB</code> and
<code class="code">GiB</code> for gigabyte and gigibyte, and so on.  Such arguments are
designated by <var class="var">byte-size</var> in the following text.  Refer to the NIST,
IEC, and other relevant national and international standards for the full
listing and explanation of the binary and decimal byte size prefixes.
</p>

<p>See <a class="xref" href="Option-Index.html">Option Index</a>, for an index to GCC&rsquo;s options.
</p>


<ul class="mini-toc">
<li><a href="Option-Summary.html" accesskey="1">Option Summary</a></li>
<li><a href="Overall-Options.html" accesskey="2">Options Controlling the Kind of Output</a></li>
<li><a href="Invoking-G_002b_002b.html" accesskey="3">Compiling C++ Programs</a></li>
<li><a href="C-Dialect-Options.html" accesskey="4">Options Controlling C Dialect</a></li>
<li><a href="C_002b_002b-Dialect-Options.html" accesskey="5">Options Controlling C++ Dialect</a></li>
<li><a href="Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options.html" accesskey="6">Options Controlling Objective-C and Objective-C++ Dialects</a></li>
<li><a href="Diagnostic-Message-Formatting-Options.html" accesskey="7">Options to Control Diagnostic Messages Formatting</a></li>
<li><a href="Warning-Options.html" accesskey="8">Options to Request or Suppress Warnings</a></li>
<li><a href="Static-Analyzer-Options.html" accesskey="9">Options That Control Static Analysis</a></li>
<li><a href="Debugging-Options.html">Options for Debugging Your Program</a></li>
<li><a href="Optimize-Options.html">Options That Control Optimization</a></li>
<li><a href="Instrumentation-Options.html">Program Instrumentation Options</a></li>
<li><a href="Preprocessor-Options.html">Options Controlling the Preprocessor</a></li>
<li><a href="Assembler-Options.html">Passing Options to the Assembler</a></li>
<li><a href="Link-Options.html">Options for Linking</a></li>
<li><a href="Directory-Options.html">Options for Directory Search</a></li>
<li><a href="Code-Gen-Options.html">Options for Code Generation Conventions</a></li>
<li><a href="Developer-Options.html">GCC Developer Options</a></li>
<li><a href="Submodel-Options.html">Machine-Dependent Options</a></li>
<li><a href="Spec-Files.html">Specifying Subprocesses and the Switches to Pass to Them</a></li>
<li><a href="Environment-Variables.html">Environment Variables Affecting GCC</a></li>
<li><a href="Precompiled-Headers.html">Using Precompiled Headers</a></li>
<li><a href="C_002b_002b-Modules.html">C++ Modules</a></li>
</ul>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="C-Implementation.html">C Implementation-Defined Behavior</a>, Previous: <a href="Standards.html">Language Standards Supported by GCC</a>, Up: <a href="index.html">Introduction</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
